//
//  TestViewController.m
//  NavTest
//
//  Created by Clavis on 2019/2/19.
//  Copyright © 2019 Clavis. All rights reserved.
//

#import "TestViewController.h"
#import "UIViewController+Cloudox.h"

@interface TestViewController ()

@end

@implementation TestViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
//    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
//    //去掉导航栏底部的黑线
//    self.navigationController.navigationBar.shadowImage = [UIImage new];
    
    self.view.backgroundColor = UIColor.orangeColor;
}

//- (void)viewWillAppear:(BOOL)animated {
//    [super viewWillAppear:animated];
//    
//    
//    // method 1
////    self.navigationController.navigationBar.translucent = YES;
////    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
////    //去掉导航栏底部的黑线
////    self.navigationController.navigationBar.shadowImage = [UIImage new];
//    
//    
//    // method 2
//    self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
//    UIImage *image = [self createAImageWithColor:[UIColor clearColor] alpha:0.0];
//    [self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
//}


- (UIImage *)createAImageWithColor:(UIColor *)color alpha:(CGFloat)alpha{
    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextSetAlpha(context, alpha);
    CGContextFillRect(context, rect);
    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return theImage;
}


- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    self.navBarBgAlpha = @"0.0";
}


@end
